package cn.test.config;

import cn.test.pojo.vo.StockInfoConfig;
import cn.test.utils.IdWorker;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * @author bigBear
 * @version 1.0
 * @date 2024-10-17 13:38
 */
//加载VO对象
@EnableConfigurationProperties(StockInfoConfig.class)
@Configuration
public class CommonConfig {

    /**
     * 密码加密
     * BCryptPasswordEncoder方法采用SHA-256对密码进行加密
     *
     * @return
     */
    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }

    /**
     * 配置id生成器bean
     *
     * @return
     */
    @Bean
    public IdWorker idWorker() {
        //对机房和机器的编号划定
        return new IdWorker(1L, 2L);
    }
}
